<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../house/static/layui/css/layui.css" media="all" />
</head>
<body>
<form class="layui-form"  id="test">
    <div class="layui-form-item">
        <label class="layui-form-label">客户编号 </label>
        <div class="layui-input-block">
            <input type="text" name="cid"  id="cid" lay-verify="required" placeholder="请输入客户编号" autocomplete="off" class="layui-input"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">租户姓名 </label>
        <div class="layui-input-block">
            <input type="text" name="cname"  id="cname" lay-verify="required" placeholder="请输入客户姓名" autocomplete="off" class="layui-input"/>
        </div>
    </div>
    <div class="layui-from-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-block">
            <input type="radio" name="sex"  value="男" title="男" checked class="layui-input">
            <input type="radio" name="sex"  value="女" title="女" class="layui-input">
        </div>
    </div>
    <div class=" layui-form-item">
        <label class="layui-form-label">工作单位</label>
        <div class="layui-input-block">
            <input type="text" name="address"  id="address"  placeholder="请输入工作单位" autocomplete="off" class="layui-input"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电话</label>
        <div class="layui-input-block">
            <input type="text" name="phone"  id="phone" lay-verify="phone" placeholder="请输入电话号码" autocomplete="off" class="layui-input"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">身份证编号</label>
        <div class="layui-input-block">
            <input name="cardid" id="cardID" lay-verify="identity" placeholder="请输入身份证编号" class="layui-input"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea name="remark" id="remark" placeholder="备注" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo"> 立即提交</button>
            <button type="reset" class="layui-btn " lay-btn-primary> 重置</button>
        </div>
    </div>
</form>
<script type="text/javascript" src="../house/static/layui/layui.js" ></script>
<script type="text/javascript" src="../house/static/js/jquery.min.js" ></script>
<script>
    layui.use(['form','layer'],function(){
        var form=layui.form;
        var layer=layui.layer;
        //监听提交
        form.on('submit(formDemo)',function(data){
            $.ajax({
                url:'customerAdd',
                data:$("#test").serialize(),//表单序列化，可以快速获地取表单的全部属性值
                type:'post',
                success:function(obj){
                    if(obj.code==0){
                        layer.msg("添加成功",{icon:6});
                        window.location.href="customer.html";
                    }else{
                        layer.msg("添加失败",{icon:5});
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });
</script>
</body>
</html>